package com.itheima.user.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.common.vo.PageResultVo;
import com.itheima.common.vo.ResultVo;
import com.itheima.user.dto.ApUserRealnamePageRequestDto;
import com.itheima.user.pojo.ApUserRealname;
import com.itheima.user.service.ApUserRealnameService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.itheima.core.controller.AbstractCoreController;

import javax.management.Query;
import java.util.Map;

import static com.baomidou.mybatisplus.core.toolkit.Wrappers.query;

/**
 * @description <p>APP实名认证信息</p>
 *
 * @version 1.0
 * @package com.itheima.user.controller
 */
@Api(value="ApUserRealnameController",tags = "APP实名认证信息")
@RestController
@RequestMapping("/auth")
@Slf4j
public class ApUserRealnameController extends AbstractCoreController<ApUserRealname> {

    private ApUserRealnameService apUserRealnameService;

    @Autowired
    public ApUserRealnameController(ApUserRealnameService apUserRealnameService) {
        super(apUserRealnameService);
        this.apUserRealnameService=apUserRealnameService;
    }

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @ApiOperation("分页查询")
    @PostMapping("/list")
    public PageResultVo<ApUserRealname> findPage(@RequestBody ApUserRealnamePageRequestDto dto){
        return apUserRealnameService.findPage(dto);
    }

    @ApiOperation("审核驳回")
    @PostMapping("/authFail")
    public ResultVo<ApUserRealname> authFail(@RequestBody Map<String,Object> map){
        //获取到前端的{id: 2, msg: "adjjfj "}值
        //修改状态为2，加上原因， 更新数据
        apUserRealnameService.authFail(map);
        return ResultVo.ok();
    }

    /**
     * 点击通过审核，发起远程调用，修改状态值
     */
    @ApiOperation("审核通过")
    @PostMapping("/authPass")
    public ResultVo<ApUserRealname> authPass(@RequestBody Map<String,Object> map){
        //
        log.debug("通过请求来了========================");
        apUserRealnameService.authPass(map);
        return ResultVo.ok();
    }


}

